<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改快递发货')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-orders-edit" th:object="${orders}">
            <input name="ordersId" th:field="*{ordersId}" type="hidden">
            <input name="openId" th:field="*{openId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <select id="state" name="state" class="form-control m-b" th:with="type=${@dict.getType('core_state')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{state}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">收货地址：</label>
                <div class="col-sm-8">
                    <input name="orderAddress" th:field="*{orderAddress}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">收货人：</label>
                <div class="col-sm-8">
                    <input name="consignee" th:field="*{consignee}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">联系电话：</label>
                <div class="col-sm-8">
                    <input name="tel" th:field="*{tel}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="descn" th:field="*{descn}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" id="expressNumber">
                <label class="col-sm-3 control-label">快递单号：</label>
                <div class="col-sm-8">
                    <input name="expressNumber" th:field="*{expressNumber}" class="form-control" type="text" required="required">
                </div>
            </div>
            <div class="form-group" id="logisticsName">
                <label class="col-sm-3 control-label">快递名称：</label>
                <div class="col-sm-8">
                    <input name="logisticsName" th:field="*{logisticsName}" class="form-control" type="text" required="required">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        if ([[${orders.state}]]==0){
            $("#expressNumber").hide();
            $("#logisticsName").hide();
        }
        $("#state").bind("change",function () {
            if ($("#state").val() == 0) {
                $("#expressNumber").hide();
                $("#logisticsName").hide();
            } else {
                $("#expressNumber").show();
                $("#logisticsName").show();
            }
        })

        var prefix = ctx + "core/orders";
        $("#form-orders-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-orders-edit').serialize());
            }
        }
    </script>
</body>
</html>